package cn.iocoder.yudao.module.hs.dal.mysql.materialbox;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.hs.controller.admin.materialbox.vo.MaterialBoxPageReqVO;
import cn.iocoder.yudao.module.hs.dal.dataobject.materialbox.MaterialBoxDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 物料箱信息 Mapper
 *
 * @author 航盛
 */
@Mapper
public interface MaterialBoxMapper extends BaseMapperX<MaterialBoxDO> {

    default PageResult<MaterialBoxDO> selectPage(MaterialBoxPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<MaterialBoxDO>()
                .likeIfPresent(MaterialBoxDO::getCode, reqVO.getCode())
                .eqIfPresent(MaterialBoxDO::getWarehouseId, reqVO.getWarehouseId())
                .likeIfPresent(MaterialBoxDO::getTrayCode, reqVO.getTrayCode())
                .eqIfPresent(MaterialBoxDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(MaterialBoxDO::getWarehousingTime, reqVO.getWarehousingTime())
                .betweenIfPresent(MaterialBoxDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(MaterialBoxDO::getId));
    }

    default List<MaterialBoxDO> selectListByTrayCode(String trayCode) {
        return selectList(MaterialBoxDO::getTrayCode, trayCode);
    }
}